package com.ning.activitys.skysound.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.ning.activitys.skysound.R;

/**
 * Created by dllo on 16/1/24.
 */
public class GameActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView tvScore;
    private int score;
    private static GameActivity gameActivity = null;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_game);

        tvScore = (TextView) findViewById(R.id.score_tv);

        findViewById(R.id.btn_finish_game_activity).setOnClickListener(this);


    }


    //MainActivity被构建的时候给mainActivity赋值
    public GameActivity() {
        gameActivity = this;
    }

    //Static 能在外界访问到MainActivity实例
    public static GameActivity getMainActivity() {
        return gameActivity;
    }

    //清除分数的方法
    public void clearScore() {
        score = 0;
        showScore();
    }

    //显示的方法
    public void showScore() {
        tvScore.setText(score + "");
    }

    //添加分数的方法
    public void addScore(int s) {
        score += s;
        showScore();
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_finish_game_activity:
                finish();
                break;
        }
    }
}
